package lormi.meipin.service.impl;


import java.util.List;

import org.springframework.stereotype.Service;

import lormi.meipin.entity.PositionClass;
import lormi.meipin.exception.LMException;
import lormi.meipin.service.BaseService;
import lormi.meipin.service.IPositionClassService;
import lormi.meipin.util.CacheUtil;

@Service
@SuppressWarnings("unchecked")
public class PositionClassService extends BaseService implements IPositionClassService{

	@Override
	public PositionClass getById(Integer id) {
		return positionClassMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<PositionClass> getOnePositionClass() throws LMException {
		List<PositionClass> list = (List<PositionClass>) CacheUtil.getCacheUtil().getOtherCache("getOnePositionClass");
		if (list==null) {
			list = positionClassMapper.selectByParentid(0);
			CacheUtil.getCacheUtil().setOtherCache("getOnePositionClass", list);
		}
		return list;
	}

	@Override
	public List<PositionClass> getTwoPositionClass(Integer id) throws LMException {

		List<PositionClass> list = (List<PositionClass>) CacheUtil.getCacheUtil().getOtherCache("getTwoPositionClass_"+id);
		if (list==null) {
			list = positionClassMapper.selectByParentid(id);
			CacheUtil.getCacheUtil().setOtherCache("getTwoPositionClass_"+id, list);
		}
		return list;
	}
	
}
